home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / eflibpt4.zip / DEMO / DATATYPE / TRANSFER.PAS < prev    next >
Pascal/Delphi Source File  |  1996-08-18  |  2KB  |  48 lines

  1. { Borland Pascal Extended Function Library - EFLIB (C) Johan Larsson, 1996
  2.   Demonstration; import and export to other data types and to data streams
  3.  
  4.   EFLIB IS PROTECTED BY THE COPYRIGHT LAW AND MAY NOT BE COPIED, SOLD OR
  5.   MANIPULATED. FOR MORE INFORMATION, SEE PROGRAM MANUAL! THIS DEMONSTRAT-
  6.   ION PROGRAM MAY FREELY BE USED AND DISTRIBUTED.                          }
  7.  
  8.  
  9. uses EFLIBDEF, EFLIBINI, EFLIBDAT, EFLIBIO;
  10.  
  11.  
  12. var DataType1 : ArrayListObjectType; DataType2 : LinkedListObjectType;
  13.     Stream : FileStreamObjectType; SomeData : string; Index : word;
  14.  
  15. begin
  16.      DataType1.Initialize (9, SizeOf(String));
  17.      DataType2.Initialize (SizeOf(String));
  18.  
  19.      { Create two duplicate data types }
  20.      SomeData := '1'; DataType1.Add (SomeData); DataType2.Add (SomeData);
  21.      SomeData := '2'; DataType1.Add (SomeData); DataType2.Add (SomeData);
  22.      SomeData := '3'; DataType1.Add (SomeData); DataType2.Add (SomeData);
  23.  
  24.      { Export second data types element into the first, and then let the
  25.        first data type import the same elements one more time. }
  26.      DataType2.Export (@DataType1);
  27.      DataType1.Import (@DataType2);
  28.  
  29.      WriteLn ('* First data type; lot''s of imported elements *');
  30.      for Index := 1 to DataType1.Elements do
  31.          Write ('[', Index:1, ']: ', String(DataType1.ElementPointer(Index)^):1, '':2);
  32.  
  33.      { Import and export elements to DataType1 file stream }
  34.      with Stream do begin
  35.           Initialize ('elements.$$$', 2000);
  36.           DataType1.StreamExport (@Stream);
  37.           Intercept;
  38.      end;
  39.  
  40.      WriteLn; WriteLn ('* Second data type; the original elements *');
  41.      for Index := 1 to DataType2.Elements do
  42.          Write ('[', Index:1, ']: ', String(DataType2.ElementPointer(Index)^):1, '':2);
  43.  
  44.      DataType1.Intercept; DataType2.Intercept;
  45.  
  46.      DeleteFile ('elements.$$$');
  47.      if GlobalDataError then WriteLn ('Error(s) reported!');
  48. end.